import { ref, watchEffect } from 'vue'
import * as storageFunc from '../util/todoStorage.js'

export function useTodoList() {
  let todoListRef = ref(storageFunc.fetchTodoList())
  watchEffect(() => {
    storageFunc.setTodoList(todoListRef.value)
  })
  window.todoListRef = todoListRef
  return {
    todoListRef
  }
}